﻿using System.Collections.ObjectModel;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using MyCalManager.Data;
using MyCalManager.Helper;
using MyCalManager.Model;
using WPFLocalization;

namespace MyCalManager.ViewModel
{
    public class MonthViewModel : ViewModelBase
    {
        private CoreData data = CoreData.Instance;

        public MonthViewModel()
        {
            Initialize();
        }

        private void Initialize()
        {
            this.Months = this.data.GetMonths();
            this.Title = "Month Overview : " + LocalizationManager.ResourceManager.GetObject("SumLbl").ToString() + this.data.GetDiff() + " Kg";
            this.Back = new RelayCommand(
                () => OnBack());
        }

       


        #region Commands

        public RelayCommand Back
        {
            get;
            private set;
        }

        private void OnBack()
        {
            Navigator n = new Navigator();
            n.Result = NavigateResult.None;
            n.To = NavigateTo.Main;
            Messenger.Default.Send(n);
        }

        #endregion

        #region Propertys

        public const string MonthsPropertyName = "Months";
        private ObservableCollection<MonthItem> _myMonths;
        public ObservableCollection<MonthItem> Months
        {
            get
            {
                return _myMonths;
            }

            set
            {
                if (_myMonths == value)
                {
                    return;
                }

               
                _myMonths = value;

                // Update bindings, no broadcast
                RaisePropertyChanged(MonthsPropertyName);
                
            }
        }

        
        public const string TitlePropertyName = "Title";
        private string _myTitle = "Month Overview";
        public string Title
        {
            get
            {
                return _myTitle;
            }

            set
            {
                if (_myTitle == value)
                {
                    return;
                }

                
                _myTitle = value;

                // Update bindings, no broadcast
                RaisePropertyChanged(TitlePropertyName);

                
            }
        }


        #endregion


    }
}